using System;
using AutoPoco.Engine;

namespace Autopoco.Contrib.DataSources
{
    public class RandomDoubleSource : DatasourceBase<double>
    {
        private readonly double _multiple;
        private readonly int _precision;

        public RandomDoubleSource(double multiple, int precision)
        {
            _multiple = multiple;
            _precision = precision;
        }

        public RandomDoubleSource()
            : this(1000, 2)
        {
        }


        private readonly Random _random = new Random(100);
        public override double Next(IGenerationSession session)
        {
            return Math.Round(_random.NextDouble() * _multiple, _precision);
        }
    }
}